package br.inf.ufrgs.usixml4desktop.rendering;

import java.awt.Container;
import java.awt.LayoutManager;

import org.jdom.Element;

import br.inf.ufrgs.usixml4desktop.exceptions.ParsingErrorException;
import br.inf.ufrgs.usixml4desktop.exceptions.RenderingErrorException;

public abstract class UsiXMLLayoutManagerRenderer{
	
	public abstract boolean validateElement(Element element);
	public abstract String getValidElementName();
	public abstract Container processRenderization(Element element, Container contentPane)
		throws RenderingErrorException, ParsingErrorException;
	
	public abstract UsiXMLLayoutManagerRenderer getNextRenderer();
	
	protected UsiXMLInterfaceRenderer usiXMLInterfaceRenderer = null;
	
	public UsiXMLLayoutManagerRenderer(UsiXMLInterfaceRenderer usiXMLInterfaceRenderer) {
		this.usiXMLInterfaceRenderer = usiXMLInterfaceRenderer;
	}
	
	public Container renderElement(Element element, Container contentPane) 
		throws RenderingErrorException, ParsingErrorException{
		
		if (element.getName().equals(this.getValidElementName())){
			return this.processRenderization(element, contentPane);
		}else{
			return this.getNextRenderer().renderElement(element,contentPane);
		}
		
	};
	
	public Object processRenderization(Element element)
		throws RenderingErrorException{
		return null;
	};
}
